package com.google.code.jmarias.server.tcp;

import com.google.code.jmarias.common.AbstractUser;
import com.google.code.jmarias.common.action.AbstractAction;
import com.google.code.jmarias.common.action.SignedAction;
import java.util.Queue;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @TODO vytvorit abstraktniho predka pro LocalServer a RemoteServer
 * @author Ondrej Michal
 */
public class LocalServer {

    private static Log log = LogFactory.getLog(LocalServer.class);

    /** Fronta pro akce zasilane serveru */
    private Queue<SignedAction> clientToServerActions;

    private AbstractUser owner;

    public LocalServer(Queue<SignedAction> clientToServerActions, AbstractUser owner) {
        this.clientToServerActions = clientToServerActions;
        this.owner = owner;
    }

    public void sendAction(AbstractAction action) {
        log.debug("Lokalni hrac " + owner + " odesila serveru akci " + action);

        clientToServerActions.offer(new SignedAction(owner, action));
    }
}
